package com.gaofans.nrpc.common.processor;

import java.util.Objects;

/**
 * rpc服务信息
 * @author GaoFans
 */
public class ServiceAuthority {


    private final String host;
    private final int port;

    public ServiceAuthority(String host, int port) {
        this.host = host;
        this.port = port;
    }

    public String getHost() {
        return host;
    }

    public int getPort() {
        return port;
    }

    @Override
    public String toString() {
        return "ServiceAuthority{" +
                "host='" + host + '\'' +
                ", port=" + port +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ServiceAuthority)) return false;
        ServiceAuthority that = (ServiceAuthority) o;
        return getPort() == that.getPort() && Objects.equals(getHost(), that.getHost());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getHost(), getPort());
    }
}
